<#assign resources="${rc.contextPath}/resources">
<#assign path="${rc.contextPath}">
<head>
<meta charset="UTF-8">
    <title>商品详情</title>	
    <script >
		var path='${path}';
	</script>
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="${resources}/css/common.css" type="text/css">
    <link href="${resources}/plugins/fontAwesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">
      <link href="${resources}/css/payBill.css" rel="stylesheet" type="text/css">
      
     <#include "setwxshare.ftl"/>
</head>


<body style="height: 100%; background-color: #F0EFED;">
<div id="container">
    <!--header-->
    
     <div class="commonHeader">订单支付
            <a href="javascript:history.back(-1);" class="fa fa-chevron-left back"></a>
       </div>
<div id="wrapper">
    <div class="goods content">
        <ul>
        	 
        	<#list  vo.cartItem as cartitem>
	            <li>
	                <div class="goodsImg">
	                    <img src="${cartitem.goods.picurl}">
	                </div>
	                <h3 class="goodsName">${cartitem.goods.name}</h3>
	                <p class="price">
	                    <span>￥${cartitem.price}元</span>
	                    <span class="goodsNum">x${cartitem.amount}</span>
	                </p>
	            </li>
            </#list>
			       
        </ul>
	<!--
        <div class="total">
            <span>小计</span>
            <span class="totalPrice">￥${vo.total}</span>
        </div>
	-->    
  </div>

    <ul class="list">
        <!-- <li id="useCoupon">
            <span>使用优惠券</span>
            <input type="radio" class="radio" name="coupon">
        </li>
        <li>
            <span>不使用优惠券</span>
            <input type="radio" class="radio" name="coupon" checked>
        </li> -->
        <li>
            <span>订单总价</span>
            <span class="textOrange pullRight"><#if activity??>(${activity})</#if>&nbsp;&nbsp;<span class="orderPrice" id= "total">￥${vo.total}</span><span class="couponInfo"></span></span>
        </li>
        <li>
         	<p>您绑定的手机号码</p>
                <p class="bandPhone" href="javascript:void(0)">
				  	<#if phone == null>
                      	<span>未绑定</span>
			      		<a class="pullRight bind">绑定新号码 <span class="fa fa-angle-right"></span></a>
					<#else>	
			  			<span>${phone}</span>
					</#if>
        	 </p>
        </li>
        <li>
        
        	<#if memberAddress??>
            <a href="${path}/manage/address/select?returnURL=/manage/commodityOrder/order/${marketId}">
                <p>
                    <span>${memberAddress.name}</span>
                    <span class="pullRight">${memberAddress.telephone}</span>
                </p>
                <p>${memberAddress.address}</p>
            </a>
            <#else>
             <a href="${path}/manage/address/select?returnURL=/manage/commodityOrder/order/${marketId}">请绑定收货地址</a>
            </#if>
        
            
        </li>
       
    </ul>

    <a id="submit" href="javascript:void(0)" onclick="submitOrder()"  >提交订单</a>
</div>
	<input type="hidden" id="couponRecord" value="0">
   <!-- <div class="coupon">
        <h3 class="title">优惠券</h3>
        <div class="coupon-box">
            <ul>
            	<#list  couponRecords as couponRecord>
                <li>
                    <div class="amount"><span class="num"></span><span>${couponRecord.rule.usageAmount}元</span></div>
                    <div class="condition">订单满${couponRecord.rule.minAmount}元使用</div>
                    <div class="deadline">使用期限 ${couponRecord.rule.startTime}-${couponRecord.rule.endTime}</div>
                    <span class="use-coupon" onclick="couponRecord(${couponRecord.id},${couponRecord.rule.usageAmount})">使用</span>
                </li>
                </#list>
            </ul>
        </div>
    </div>--> 
 	<input type="hidden" value="${memberAddress.id}" id="addressid">
    <input type="hidden" value="${phone}" id="telephone">
    <input type="hidden" value="1" id="pickedId">

    <div class="mask"></div>
</div>


</body>

<script src="${resources}/plugins/jquery/2.2.2/jquery.min.js"></script>
<script src="${resources}/js/common.js"></script>
<script src="${resources}/js/payBill.js"></script>
<script type="text/javascript">
	//优惠券方法
	function couponRecord(couponRecordId,usageAmount){
		$("#couponRecord").val(couponRecordId);
		$("#total").html("￥"+parseFloat(${vo.total}-usageAmount).toFixed(2)+"(优惠券抵消"+parseFloat(usageAmount).toFixed(2)+"元)");
		
	}
	
	function submitOrder(){
 		var addressid = $("#addressid").val();
 		var telephone = $("#telephone").val();

	  	if(telephone==""){
      		common.alert({content:"请绑定手机号码"});
         	return;
       	} 
		if(addressid==""){
			common.alert({content:"请选择收货地址"});
			return;	
		}

		//优惠券ID
		var couponRecordId=$("#couponRecord").val();
		//地址ID
		var addressId=$("#addressid").val();
		//自提点ID
		var pickedId=$("#pickedId").val();	

		$.ajax({
 	        url: "${path}/manage/commodityOrder/create",
 	        type: "post",
 	        data:{
 	        	"marketid":"${marketId}",
 	        	"addressid":addressId,
 	        	"couponRecordId":couponRecordId,
 	        	"paymode":"1",
 	        	"pickedId":pickedId
 	        },
 	        success: function(data) {
 	        	if(data.code == "000"){
 	        		window.location.href="${path}/pay/"+data.result;
 	        	}else if(data.code == "300"){
 	        		common.alert({
					    dialog: true,
						content:data.msg
					})
 	        	}
 	        }
 	    });	
	}
</script>


